/**
 * 清单目录的操作api
 */
import request from "@/utils/request";

/**
 * 查询分页数据
 * @param {*} params
 * @returns
 */
export function queryPages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/listCatalogue/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 保存或修改数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/listCatalogue/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 切换清单目录状态
 * @param {*} params
 * @returns
 */
export function tiggerStatus(params) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/listCatalogue/tiggerStatus",
    method: "get",
    params: params
  });
}

/**
 * 根据id删除清单目
 * @param {*} id
 * @returns
 */
export function deleteById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/listCatalogue/deleteById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 查询所有启用的清单目录数据
 * @returns
 */
export function queryAbleAll() {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/listCatalogue/queryAbleAll",
    method: "get"
  });
}

/**
 * 根据主键id查询
 * @param {*} id
 */
export function queryById(id) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/listCatalogue/queryById/${id}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 查询登录人的权限 清单目录分页数据
 * @param {*} params
 * @returns
 */
export function queryPagesByAuth(params = {}) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/listCatalogue/queryPagesByAuth",
    method: "get",
    params: params
  });
}

/**
 * 校验这个目录是否关联了未删除的清单数据
 * @param {*} catalogueOid
 * @returns
 */
export function hasExistRelHdl(catalogueOid = "-1") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/listCatalogue/hasExistRelHdl/${catalogueOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
